home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
Heap
/
HeapLink.h
< prev
Wrap
Text File
|
2000-06-23
|
1KB
|
55 lines
// HeapLink.h
#ifndef HeapLink_h
#define HeapLink_h
#ifndef Integers_h
#include "Integers.h"
#endif
#ifndef Assert_h
#include "Assert.h"
#endif
template < class Element > class Heap;
template < class Element >
class HeapLink
{
typedef Element ElementType;
typedef HeapLink< Element > LinkType;
typedef Heap< Element > HeapType;
typedef bool (ElementType::*Comparator)( const Element& ) const;
friend class Heap< Element >;
private:
Element *body;
HeapType *heap;
uint32 path;
LinkType *children[2];
void SwapWith( LinkType& );
bool operator<=( const LinkType& ) const;
bool operator>( const LinkType& r ) const { return !( *this <= r ); }
public:
HeapLink( Element *e = 0 );
~HeapLink();
bool Listed() const { return heap != 0; }
HeapType& Heap() const { Assert( heap != 0 ); return *heap; }
bool Null() const { return body == 0; }
Element *Target() const { return body; }
void PointTo( Element *b ) { body = b; }
Element& operator*() const { Assert( body != 0 ); return *body; }
Element *operator->() const { Assert( body != 0 ); return body; }
};
#ifndef HeapLink_cp
#include "HeapLink.cp"
#endif
#endif